package com.yuandian.ops.workbench.controller;

import com.yuandian.api.management.entity.ConfAlarmIndicators;
import com.yuandian.api.management.feign.RemoteAlarmIndicatorsService;
import com.yuandian.bpm.common.core.util.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 响应慢业务告警controller
 * <p>
 *
 * @author lijunhang
 * @date 2021/7/7
 * @since 1.0.0
 */
@RestController
@RequestMapping("/ywgzt/alarm/responSlow")
@Api(tags = "响应慢业务告警controller")
public class ResponseSlowBusiAlarmController {

    private static Logger log = LoggerFactory.getLogger(ResponseSlowBusiAlarmController.class);

    @Autowired
    private RemoteAlarmIndicatorsService remoteAlarmIndicatorsService;

    /**
     * 获取基础告警类型
	 */
    @PostMapping("queryBaseAlarmTypes")
	@ApiOperation(value = "告警详情分析-获取基础告警类型", notes = "告警详情分析-获取基础告警类型")
    public R<Object> queryBaseAlarmTypes() {
		List<ConfAlarmIndicators> data = new ArrayList<>();
		try {
			long sTime = System.currentTimeMillis();
			ConfAlarmIndicators confAlarmIndicators = new ConfAlarmIndicators();
			confAlarmIndicators.setIsEnable(0);
			confAlarmIndicators.setType(1);
			confAlarmIndicators.setCategory("BPM");
			data = remoteAlarmIndicatorsService.list(confAlarmIndicators).getData();

			log.info("[运维工作台]-[远程调用-后台配置服务]-[获取基础告警类型指标]-耗时: {} MS", System.currentTimeMillis() - sTime);

		} catch (Exception e) {
			e.printStackTrace();
			log.error("[运维工作台]-[远程调用-后台配置服务]-[获取基础告警类型指标]报错: {}" + e.getMessage());
		}

        return R.ok(data);
    }


}
